package com.atguigu.tingshu.payment.api;

import com.atguigu.tingshu.common.login.GuiGuLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.payment.service.WxPayService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Tag(name = "微信支付接口")
@RestController
@RequestMapping("api/payment")
@Slf4j
public class WxPayApiController {

    @Autowired
    private WxPayService wxPayService;

    /**
     * 创建jsapi
     *
     * @param paymentType 支付类型
     * @param orderNo     订单号
     * @return {@link Result<Map<String,String>>}
     */
    @GuiGuLogin
    @PostMapping("wxPay/createJsapi/{paymentType}/{orderNo}")
    public Result<Map<String,String>> createJsapi(@PathVariable String paymentType,@PathVariable String orderNo) {
        return Result.ok(wxPayService.createJsapi(paymentType, orderNo));
    }

}
